<template>
	<view>
		<!-- 控件列表 -->
		<view>
			<!-- 输入框 -->
			<view>
				<!-- 单行 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'comInput' || item.__config__.jnpfKey == 'numInput'">
						<comInput v-model="formData[item.__vModel__]" :disabled="judge(item.__vModel__)" :type="item.__config__.jnpfKey"
							:maxlength='item.maxlength==null?controlProerty.maxlength:item.maxlength'
							:placeholder="item.placeholder" :required='item.__config__.required'
							:showLabel='item.__config__.showLabel' :label='item.__config__.label' :vModel='item.__vModel__' :formOperates='formOperates'></comInput>
					</view>
				</view>
				

				<!-- 多行 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'textarea'">
						<ymTextarea v-model='formData[item.__vModel__]' :disabled="judge(item.__vModel__)"
							:type="item.__config__.jnpfKey" :placeholder="item.placeholder"
							:maxlength='item.maxlength==null?controlProerty.maxlength:item.maxlength'
							:required='item.__config__.required' :showLabel='item.__config__.showLabel'
							:label='item.__config__.label'></ymTextarea>
					</view>
				</view>
				
			</view>



			<!-- 公司,部门,用户,岗位树组件 -->
			<view
				v-if="item.__config__.jnpfKey == 'comSelect' || item.__config__.jnpfKey == 'depSelect' || item.__config__.jnpfKey == 'userSelect' || item.__config__.jnpfKey == 'posSelect'">

				<!-- 公司 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'comSelect'">
						<comSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel'
							:placeholder="item.placeholder" :label='item.__config__.label'
							:required='item.__config__.required' :disabled="judge(item.__vModel__)"
							:jnpfKey='item.__config__.jnpfKey' :vModel='item.__vModel__'
							:defaultValue='item.__config__.defaultValue'></comSelect>
					</view>
				</view>
				

				<!-- 部门 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'depSelect'">
						<depSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel'
							:placeholder="item.placeholder" :label='item.__config__.label'
							:required='item.__config__.required' :disabled="judge(item.__vModel__)"
							:jnpfKey='item.__config__.jnpfKey' :vModel='item.__vModel__'></depSelect>
					</view>
				</view>
				

				<!-- 用户 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'userSelect'">
						<userSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel'
							:placeholder="item.placeholder" :label='item.__config__.label'
							:required='item.__config__.required' :disabled="judge(item.__vModel__)"
							:jnpfKey='item.__config__.jnpfKey' :vModel='item.__vModel__'></userSelect>
					</view>
				</view>
				

				<!-- 岗位 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'posSelect'">
						<posSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel'
							:placeholder="item.placeholder" :label='item.__config__.label'
							:required='item.__config__.required' :disabled="judge(item.__vModel__)"
							:jnpfKey='item.__config__.jnpfKey' :vModel='item.__vModel__'></posSelect>
					</view>
				</view>
				

			</view>




			<!-- 选择框 -->
			<view v-if="$formOperates.read(item.__vModel__,formOperates)">
				<view v-if="item.__config__.jnpfKey == 'checkbox' || item.__config__.jnpfKey == 'radio' || item.__config__.jnpfKey == 'select'">
					<staticSelect v-model="formData[item.__vModel__]" :jnpfKey='item.__config__.jnpfKey'
						:label='item.__config__.label' :dataType='item.__config__.dataType' :disabled="judge(item.__vModel__)"
						:options='options[item.__vModel__]' :required='item.__config__.required'
						:showLabel='item.__config__.showLabel' :placeholder="item.placeholder"
						:propsLabel='item.__config__.props.label' :propsValue='item.__config__.props.value'
						:dictionaryType='item.__config__.dictionaryType' :isId='isId' :propsAll='item.__config__.props' :vModel='item.__vModel__' :formOperates='formOperates'>
					</staticSelect>
				</view>
			</view>
			

			<!-- 日期时间选择 -->
			<view v-if="$formOperates.read(item.__vModel__,formOperates)">
				<view v-if="item.__config__.jnpfKey == 'date' || item.__config__.jnpfKey == 'time'">
					<dateTime v-model="formData[item.__vModel__]" :jnpfKey='item.__config__.jnpfKey'
						:label='item.__config__.label' :vModel='item.__vModel__' :disabled="judge(item.__vModel__)"
						:required='item.__config__.required' :showLabel='item.__config__.showLabel'
						:placeholder="item.placeholder" :formOperates='formOperates'></dateTime>
				</view>
			</view>
			


			<!-- 树联，级联 -->
			<view v-if="$formOperates.read(item.__vModel__,formOperates)">
				<view v-if="item.__config__.jnpfKey == 'treeSelect' || item.__config__.jnpfKey == 'cascader'">
					<treeCascader v-model='formData[item.__vModel__]' :jnpfKey='item.__config__.jnpfKey'
						:showLabel='item.__config__.showLabel' :required='item.__config__.required'
						:placeholder="item.placeholder" :label='item.__config__.label' :disabled="judge(item.__vModel__)"
						:options='options[item.__vModel__]' :dictionaryType='item.__config__.dictionaryType'
						:tableModel='item.tableModel' :isId='isId' :propsAll='item.__config__.props' :formOperates='formOperates' :vModel='item.__vModel__'></treeCascader>
				</view>
			</view>
			

			<!-- 省市区选择 -->
			<view v-if="$formOperates.read(item.__vModel__,formOperates)">
				<view v-if="item.__config__.jnpfKey == 'address'">
					<addressSelect v-model='formData[item.__vModel__]' :jnpfKey='item.__config__.jnpfKey'
						:showLabel='item.__config__.showLabel' :required='item.__config__.required'
						:placeholder="item.placeholder" :label='item.__config__.label' :disabled="item.disabled"
						:vModel='item.__vModel__' :formOperates='formOperates'></addressSelect>
				</view>
			</view>
			
			

			<!-- 日期范围 -->
		<!-- 	<view v-if="item.__config__.jnpfKey == 'dateRange'">
				<rangeTime :item='item' v-model='formData[item.__vModel__]' :showLabel='item.__config__.showLabel'
					:required='item.__config__.required' :placeholder="item.placeholder" :label='item.__config__.label'
					:disabled="$formOperates.write(item.__vModel__,formOperates)"></rangeTime>
			</view> -->


			<!-- 系统自动生成的控件 -->
			
			<view v-if="$formOperates.read(item.__vModel__,formOperates)">
				<view v-if="item.__config__.jnpfKey == 'billRule' || item.__config__.jnpfKey == 'createUser' || item.__config__.jnpfKey == 'currDept' || item.__config__.jnpfKey == 'createTime' || item.__config__.jnpfKey == 'modifyUser' || item.__config__.jnpfKey == 'modifyTime' || item.__config__.jnpfKey == 'currPosition' || item.__config__.jnpfKey == 'currOrganize'">
					<autoGenerate v-model="formData[item.__vModel__]"
						:jnpfKey="item.__config__.jnpfKey" :placeholder="item.placeholder"
						:required='item.__config__.required' :showLabel='item.__config__.showLabel'
						:label='item.__config__.label' :vModel='item.__vModel__' :formOperates='formOperates'></autoGenerate>
				</view>
			</view>
			

			<!-- 其他 -->
			<view>
				<!-- 文本框 -->
				<view scroll-y="true" v-if="item.__config__.jnpfKey == 'JNPFText'">
					<JNPFText :textStyle='item.textStyle' :label='item.__config__.label'
						:defaultValue='item.__config__.defaultValue' :showLabel='item.__config__.showLabel'
						:Width='item.style'></JNPFText>
				</view>
				<!-- 分组标题 -->
				<view v-if="item.__config__.jnpfKey == 'groupTitle'">
					<groupTitle :content='item.content' :showLabel='item.__config__.showLabel'
						:label='item.__config__.label'></groupTitle>
				</view>

				<!-- 评分 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'rate'">
						<JNPFRate :showLabel='item.__config__.showLabel' :label='item.__config__.label'
							:disabled="judge(item.__vModel__)" v-model="formData[item.__vModel__]" :max='item.max'
							:readonly='item.readonly' :allowHalf='item.allowHalf' :required='item.__config__.required' :vModel='item.__vModel__' :formOperates='formOperates'>
						</JNPFRate>
					</view>
				</view>
				

				<!-- 开关 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'switch'">
						<JNPFSwitch :vModel='item.__vModel__' v-model="formData[item.__vModel__]" :disabled="judge(item.__vModel__)"
							:required='item.__config__.required' :showLabel='item.__config__.showLabel'
							:label='item.__config__.label' :formOperates='formOperates'></JNPFSwitch>
					</view>
				</view>
				

				<!-- slider滑块 -->
				<view v-if="$formOperates.read(item.__vModel__,formOperates)">
					<view v-if="item.__config__.jnpfKey == 'slider'">
						<JNPFSlider :min="item.min" :max="item.max" :step="item.step" v-model="formData[item.__vModel__]"
							:disabled="judge(item.__vModel__)" :required='item.__config__.required'
							:showLabel='item.__config__.showLabel' :label='item.__config__.label' :vModel='item.__vModel__' :formOperates='formOperates'>
						</JNPFSlider>
					</view>
				</view>
				
			</view>

			<!-- 卡片 -->
			<view v-if="item.__config__.jnpfKey == 'card'" class="uni-flex-column"
				style="margin-bottom: 20rpx; width: 100%;height: 100%;background-color: #FFFFFF; padding: 20rpx 20rpx;border: 1px dashed #E3E3E5;">
				<view class="labelSty border-bottom-E3E3E5">
					<label for="">{{item.__config__.label}}</label>
				</view>
				<formControl v-for="(card, cardIndex) in item.__config__.children" :key="cardIndex" :item='card'
					:formData="formData" />
			</view>

			<!-- 上传图片 -->
			<view v-if="$formOperates.read(item.__vModel__,formOperates)">
				<view v-if="item.__config__.jnpfKey == 'uploadImg'">
					<JNPFUpload :required='item.__config__.required' :showLabel='item.__config__.showLabel'
						:label='item.__config__.label' :vModel='item.__vModel__' v-model="formData[item.__vModel__]"
						:fileSize='item.fileSize' :limit='item.limit' :formOperates='formOperates' :upLoadDisabled='$formOperates.write(item.__vModel__,formOperates)'></JNPFUpload>
				</view>
			</view>
			

			<!-- 子表 -->
			<view v-if="$formOperates.read(item.__vModel__,formOperates)">
				<view v-if="item.__config__.jnpfKey == 'table'" style="margin-bottom: 20rpx;">
					<childTable :item='item' :value="formData[item.__vModel__]" :options='options' :isId='isId'
						:scanType='scanType' :disabled="judge(item.__vModel__)"/>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import JNPFText from '@/components/JNPFText/JNPFText.vue'
	import groupTitle from '@/components/groupTitle/groupTitle.vue'
	import staticSelect from '@/components/staticSelect/staticSelect.vue'
	import treeCascader from '@/components/treeCascader/treeCascader.vue'
	import rangeTime from '@/components/range-picker/rangeTime.vue'
	import addressSelect from '@/components/addressSelect/addressSelect.vue'
	import comSelect from '@/components/comSelect/comSelect.vue'
	import depSelect from '@/components/depSelect/depSelect.vue'
	import userSelect from '@/components/userSelect/userSelect.vue'
	import posSelect from '@/components/posSelect/posSelect.vue'
	import ymTextarea from '@/components/ym-Textarea/ym-Textarea.vue'
	import comInput from '@/components/comInput/comInput.vue'
	import dateTime from '@/components/dateTime/dateTime.vue'
	import autoGenerate from '@/components/autoGenerate/autoGenerate.vue'
	import JNPFSlider from '@/components/JNPFSlider/JNPFSlider.vue'
	import JNPFSwitch from '@/components/JNPFSwitch/JNPFSwitch.vue'
	import JNPFRate from '@/components/JNPFRate/JNPFRate.vue'
	import JNPFUpload from '@/components/JNPFUpload/JNPFUpload.vue'
	import childTable from '@/components/childTable/childTable.vue'
	export default {
		components: {

			staticSelect,
			treeCascader,
			rangeTime,
			addressSelect,
			comSelect,
			depSelect,
			userSelect,
			posSelect,
			ymTextarea,
			comInput,
			dateTime,
			autoGenerate,
			JNPFSlider,
			JNPFSwitch,
			JNPFText,
			groupTitle,
			JNPFRate,
			JNPFUpload,
			childTable
		},
		name: 'formControl',
		props: {
			formOperates:{
				type: Array,
				default(){
					return []
				}
			},
			statusType:{
				type: String,
				default(){
					return ''
				}
			},
			F_Status:{
				type: Number,
				default(){
					return 
				}
			},
			item: {
				type: Object,
				default () {
					return {}
				}
			},
			formData: {
				type: Object,
				default () {
					return {}
				}
			},
			options: {
				type: Array,
				default () {
					return [{
						fullName: '默认一',
						id: '1'
					}, {
						fullName: '默认二',
						id: '2'
					}]
				}
			},
			isId: {
				type: Boolean,
				default () {
					return false
				}
			},
			scanType: {
				type: Boolean,
				default () {
					return false
				}
			},
		},
		data() {
			return {
				tableVmodel: [],
				controlProerty: { //控件属性
					maxlength: 50,
				},

			}
		},
		created() {
			console.log(typeof(this.F_Status))
		},
		methods: {
			//判断表单权限可写
			judge(id) {
				return this.statusType == 'backlog' ? this.$formOperates.write(id,this.formOperates) : this.F_Status == 1 || this.F_Status == 2 ? true : this.$formOperates.write(id,this.formOperates)
			},
		}
	}
</script>

<style>

</style>
